package com.light.netty.client.coder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class UdpMessageEncoder extends MessageToByteEncoder<ByteBuf> {
    @Override
    protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) {
        // 添加协议头（示例：消息长度前缀）
        out.writeInt(msg.readableBytes());
        out.writeBytes(msg);
    }
}